package com.wsjj.yjh.demo;

import redis.clients.jedis.Jedis;

import java.util.List;

public class JedisDemo {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("hadoop102", 6379);
//        jedis.auth("密码");
        System.out.println(jedis.ping());
        System.out.println(jedis.get("k1"));
        jedis.set("k2","v2");
        System.out.println(jedis.get("k2"));
        System.out.println(jedis.keys("*"));
        jedis.lpush("list","aaa","bbbb","ccc");
        System.out.println(jedis.lindex("list",3L));
        System.out.println(jedis.lrange("list", 0L, 2L));
        List<String> list = jedis.lrange("list", 0L, 2L);
        for (String s : list) {
            System.out.println(s);
        }

    }
}
